package com.java.file;

import java.io.File;

/**
 * 打印文件夹下所有文件夹和文件信息
 * @author admin
 *
 */

public class SimpleFile {

	public void FilePath(String filePath, int node) {
		File fileObj = new File(filePath);
		File[] files = fileObj.listFiles();
		for (File file : files) {
			if (file.isDirectory()) {
				System.out.println(getLine(node) + file.getName());
				FilePath(file.getPath(), (node + 1));
			} else {
				System.out.println(getLine(node) + file.getName());
			}
		}

	}

	public String getLine(int node) {
		StringBuilder sb = new StringBuilder("|");
		for (int i = 0; i < node; i++) {
			sb.append("--");
		}
		return sb.toString();
	}

	public static void main(String[] args) {
		new SimpleFile().FilePath("D:/EclipseWork/javabase",1);
	}

}
